package main

import (
	"fmt"
	"net"
	"time"
)

func main() {
	// 这里去测试发送请求到server
	fmt.Println("client start...")

	time.Sleep(1 * time.Second)

	conn, err := net.Dial("tcp", "127.0.0.1:8999")
	if err != nil {
		fmt.Println("client start error: ", err)
		return
	}

	for {
		// 调用write，写入数据
		_, err := conn.Write([]byte("hello Zinx V0.2"))
		if err != nil {
			fmt.Println("write conn err: ", err)
			return
		}
		buff := make([]byte, 512)
		cnt, err := conn.Read(buff)
		if err != nil {
			fmt.Println("read buff err: ", err)
			return
		}
		fmt.Printf("response: %s, cnt = %d \n", buff, cnt)

		// cup 阻塞下
		time.Sleep(1 * time.Second)
	}
}
